package com.company;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class MongoCounter extends Counter{
    private final Lock lock = new ReentrantLock();
    private int count = 0;

    public  int get(){
        return  count;
    }

    public  void add(){
        lock.lock();
        try {
            count += 1;
        }
        finally {
            lock.unlock();
        }

    }
    public  void dec(){
        lock.lock();
        try {
            count -= 1;
        }
        finally {
            lock.unlock();
        }
    }
}
